setwd("D:/ClassificationR")

setosa = iris2class[which(iris2class$Species == "setosa"),]
versicolor = iris2class[which(iris2class$Species == "versicolor"),]

#part 1
iris2class.test.1 = rbind(setosa[1:10,], versicolor[1:10,])
iris2class.train.1 = rbind(setosa[11:50,], versicolor[11:50,])
write.csv(iris2class.test.1, "iris2class.test.1.csv", row.names = FALSE)
write.csv(iris2class.train.1, "iris2class.train.1.csv", row.names = FALSE)

#part 2
iris2class.test.2 = rbind(setosa[11:20,], versicolor[11:20,])
iris2class.train.2 = rbind(setosa[c(1:10,21:50),], versicolor[c(1:10,21:50),])
write.csv(iris2class.test.2, "iris2class.test.2.csv", row.names = FALSE)
write.csv(iris2class.train.2, "iris2class.train.2.csv", row.names = FALSE)

#part 3
iris2class.test.3 = rbind(setosa[21:30,], versicolor[21:30,])
iris2class.train.3 = rbind(setosa[c(1:20,31:50),], versicolor[c(1:20,31:50),])
write.csv(iris2class.test.3, "iris2class.test.3.csv", row.names = FALSE)
write.csv(iris2class.train.3, "iris2class.train.3.csv", row.names = FALSE)

#part 4
iris2class.test.4 = rbind(setosa[31:40,], versicolor[31:40,])
iris2class.train.4 = rbind(setosa[c(1:30,41:50),], versicolor[c(1:30,41:50),])
write.csv(iris2class.test.4, "iris2class.test.4.csv", row.names = FALSE)
write.csv(iris2class.train.4, "iris2class.train.4.csv", row.names = FALSE)

#part 5
iris2class.test.5 = rbind(setosa[41:50,], versicolor[41:50,])
iris2class.train.5 = rbind(setosa[1:40,], versicolor[1:40,])
write.csv(iris2class.test.5, "iris2class.test.5.csv", row.names = FALSE)
write.csv(iris2class.train.5, "iris2class.train.5.csv", row.names = FALSE)